import logging
from datetime import datetime,timedelta
# from os import path
# curPath=path.abspath(__file__) 
# 创建一个handler，用于写入日志，输出到文件
fh = logging.FileHandler('./outboll.log',mode='a', encoding='utf-8')
 
# 创建一个handler，用于输出到屏幕
ch = logging.StreamHandler()
 
# 创建一个formatter，用于处理日志格式
formatter = logging.Formatter('%(asctime)s——%(message)s')
 
# 绑定formatter 到handler上
fh.setFormatter(formatter)
ch.setFormatter(formatter)

 # 获取logger对象，用于记录日志
logger = logging.getLogger(__name__)
# 设置一个日志记录级别
logger.setLevel(logging.INFO)
# 绑定handler到logger对象上
logger.addHandler(fh)
logger.addHandler(ch)
 
# 定义好函数，我们直接调用就可以了
 
# 记录一条日志
# logger.info('123')

# class LengthDeque(deque):
#     def __init_subclass__(cls) -> None:
#         return super().__init_subclass__()
TodayString=str(datetime.now().date())
start_1=datetime.strptime(TodayString + '8:55', '%Y-%m-%d%H:%M')
end_1=datetime.strptime(TodayString + '9:04', '%Y-%m-%d%H:%M')

start_2=datetime.strptime(TodayString + '11:27', '%Y-%m-%d%H:%M')
end_2=datetime.strptime(TodayString + '11:31', '%Y-%m-%d%H:%M')
start_3=datetime.strptime(TodayString + '13:30', '%Y-%m-%d%H:%M')
end_3=datetime.strptime(TodayString + '13:33', '%Y-%m-%d%H:%M')
start_4=datetime.strptime(TodayString + '14:57', '%Y-%m-%d%H:%M')
end_4=datetime.strptime(TodayString + '15:01', '%Y-%m-%d%H:%M')
start_5=datetime.strptime(TodayString + '21:00', '%Y-%m-%d%H:%M')
end_5=datetime.strptime(TodayString + '21:04', '%Y-%m-%d%H:%M')
start_6=datetime.strptime(TodayString + '22:57', '%Y-%m-%d%H:%M')
end_6=datetime.strptime(TodayString + '23:01', '%Y-%m-%d%H:%M')
during_ls=[(start_1,end_1),(start_2,end_2),(start_3,end_3),(start_4,end_4),(start_5,end_5),(start_6,end_6)]
def IsInMarketOpenCloseTime(during_ls=during_ls):
    '''判断当前时间是否是开收盘时间'''
    now_time = datetime.now()
    for tu in during_ls:
        start_time=tu[0]
        end_time=tu[1]
        if start_time < now_time < end_time:
            return True
        
    return False
def makeVolPriceList(startPrice,VolumeTuple,step=1):
    ls=[]
    for index,v in enumerate(VolumeTuple):
        ls.append((startPrice+index*step,v))
    return ls
def getTradeDate():
    if datetime.now().hour>20:
        date=datetime.now()+timedelta(days=1)
    else:
        date=datetime.now()
    return datetime.strftime(date,'%Y%m%d')
    


if __name__=="__main__":
    print(makeVolPriceList(3360,(1,1,2),2))